#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <stack>
#include <cstring>
#include <queue>
#include <cctype>
#include <iomanip>
#include <climits>

using i64 = signed long long;

constexpr double ESP = 1E-9;

void solve() {
    int n;
    std::cin >> n;

    std::vector<int> a(n), b(n), c(n);
    for (int i = 0; i < n; ++i) {
        std::cin >> a[i] >> b[i] >> c[i];
    }

    auto f = [&](double x) {
        double re = INT_MIN;
        for (int i = 0; i < n; ++i) {
            re = std::max(re, a[i] * x * x + b[i] * x + c[i]);
        }
        return re;
    };

    // for (int i = 0; i < 1000; i += 100) {
    //     std::cout << f(i) << " ";
    // }
    // std::cout << "\n";

    double l = 0, r = 1000;
    while (r - l > ESP) {
        auto m1 = (l * 2 + r) / 3;
        auto m2 = (l + 2 * r) / 3;
        if (f(m1) > f(m2)) {
            l = m1;
        } else {
            r = m2;
        }
    }
    std::cout << f(l) << "\n";
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int t;
    std::cin >> t;

    std::cout << std::setiosflags(std::ios::fixed) << std::setprecision(4);

    while (t--) {
        solve();
    }

    return 0;
}


int tri_search(int l,int r){
    // 求凹函数的极小值
    int f1,f2;
    while(l < r) {
        int lp = l + (r - l) / 3;
        int rp = r - (r - l) / 3;
        f1 = check(lp),f2 = check(rp);
        if(f1 <= f2) 
            r = rp - 1;
        else 
            l = lp + 1;
    }
    //查找的是极小值
    return min(f1,f2);
    //查找的是极小值对应的下标
    return f1<f2?l:r;
}

// 凸函数
int tri_search(int l,int r){
    // 求凸函数的极大值
    int f1,f2;
    while(l < r) {
        int lp = l + (r - l) / 3;
        int rp = r - (r - l) / 3;
        f1 = check(lp),f2 = check(rp);
        if(f1 >= f2) 
            l = lp + 1;
        else
            r = rp - 1;
    }
    //查找的是极大值
    return max(f1,f2);
    //查找的是极大值对应的下标
    return f1>f2?l:r;
}


// 求凹函数的极小值
int tri_search(int l,int r){
    int f1,f2;
    while(r - l > 5) {
        int lp = l + (r - l) / 3;
        int rp = r - (r - l) / 3;
        f1 = check(lp),f2 = check(rp);
        if(f1 <= f2) 
            r = rp - 1;
        else 
            l = lp + 1;
    }
    int res = check(l);
    for(int i = l + 1;i <= r; ++i){
        res = min(res,check(i));
    }
    return res;
}

// https://blog.csdn.net/weixin_45772744/article/details/123823865